﻿<!DOCTYPE html>
<!--日常评估考核管理编辑-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

    <link href="../static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="../static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        body {
            padding-bottom: 10px;
        }

        .vue-treeselect_style .vue-treeselect__control {
            height: 100%;
            border: none;
            background: none;
        }

        .vue-treeselect__placeholder {
            top: -3px;
        }

        .vue-treeselect__single-value {
            top: -3px;
        }

        .vue-treeselect__input {
            height: 27px !important;
        }
    </style>
    <style>
        body {
            padding-bottom: 10px;
        }

        h3 {
            text-align: center;
        }

        h3 .elst-select-mini {
            width: 200px;
            display: inline-block;
        }

        h3 .elst-select-mini .el-input__inner {
            font-size: 17px
        }

        .remark {
            color: #606266;
            margin-left: 40px;
            font-size: 14px;
        }

        .el-form-item__content {
            margin-left: 0px !important;
        }

        .el-form-item {
            margin-bottom: 0px !important;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak class="popupW100">
        <el-form :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="180px" size="mini"
                 label-position="right">
            <el-row>
                <h3>
                    承包商日常评估考核
                </h3>
            </el-row> <el-row style="padding-bottom:10px;">
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    <div> {{"承包商类型"+mark.m}}</div>
                                </template>
                                <el-select @visible-change="visibleChange" v-model="Form.assessTypeId" slot="suffix" @change="postChange">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in Type" :label="item.value" :value="item.id">
                                    </el-option>
                                </el-select>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" :offset="2">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    <div> {{DailyAssessment.ContractorName+mark.m}}</div>
                                </template>

                                <el-select @visible-change="visibleChange" v-model="Form.cbsListID" slot="suffix"
                                           :placeholder="DailyAssessment.ContractorName">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in CBS_Lists" :label="item.contractorName"
                                               :value="item.id"></el-option>
                                </el-select>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row> <el-row style="padding-bottom:10px;">
                <el-col :span="11">
                    <!--评估人-->
                    <div class="elst-select-mini vue-treeselect_style">
                        <el-form-item prop="OverdueScope">
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{DailyAssessment.participant+mark.m}}
                                </template>
                                <!--<treeselect v-model="Form.participant" :options="participant" :flat="true"
                        :show-count="true" :disable-branch-nodes="true" slot="suffix"
                        style="line-height:14px;" placeholder="请选择" />-->
                                <tree-department-staff-single slot="suffix" v-model="Form.assessUserId" style="line-height:28px;"></tree-department-staff-single>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.assessUserId">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" :offset="2">
                    <el-form-item prop="assessDate">
                        <el-input size="mini">
                            <template slot="prepend">
                                <div> {{DailyAssessment.assessTime+mark.m}}</div>
                            </template>
                            <el-date-picker slot="suffix" v-model="Form.assessDate" type="date" size="mini"
                                            format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择时间">
                            </el-date-picker>
                        </el-input>
                    </el-form-item>
                </el-col>
            </el-row> <el-row style="padding-bottom:10px;">
                          <el-table :data="Form.cbS_DayCheckDetail" stripe border="" show-summary style="width: 100%">
                              <el-table-column type="index" :label="col.SequenceNumber" :index="indexMethod" width="85"
                                               show-overflow-tooltip="true"></el-table-column>
                              <el-table-column prop="cbS_DayCheckItem.checkProject" :label="DailyAssessment.ExamContent">
                              </el-table-column>
                              <el-table-column prop="score" sortable :label="DailyAssessment.score">
                                  <template slot-scope="scope">
                                      <el-input type="text" v-model="scope.row.score" autocomplete="off" size="mini">
                                      </el-input>
                                  </template>
                              </el-table-column>
                              <el-table-column prop="id" width="1" :show-overflow-tooltip="true">
                                  <template slot-scope="scope">
                                      <span>{{scope.row.id}}</span>
                                  </template>
                              </el-table-column>
                          </el-table>
            </el-row> <el-row style="padding-bottom:10px;">
                <div class="el-table el-table--fit el-table--striped el-table--border el-table--enable-row-hover el-table--enable-row-transition"
                     style="width: 100%;">
                    <div class="">
                        <table cellspacing="0" cellpadding="0" border="0" class="el-table__footer" style="width: 100%">
                            <tbody class="has-gutter">
                                <tr>
                                    <td colspan="1" rowspan="1" class="el-table_1_column_1 is-leaf" style="width: 85px">
                                        <div class="cell">考核评价</div>
                                    </td>
                                    <td colspan="1" rowspan="1" class="el-table_1_column_2 is-leaf">
                                        <div class="cell">
                                            <el-form-item prop="evaluationResults">
                                                <el-input type="textarea" v-model="Form.evaluationResults" autocomplete="off">
                                                </el-input>
                                            </el-form-item>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </el-row>
            <br>
            <p class="remark">
                <strong>备注：</strong><br>
                1）此表作为操作运行类承包商月度财务结算的依据。<br>
                2）评估标准——（1）无，不达标：0分；（2）有，小部分达标：1分；（3）有，在
                部分达标：2分；（4）有，达标：3分；（5）有，好：4分；（6）有，非常好：5分；
                总分采用 100 分制。
            </p>
            <el-row type="flex" justify="end" style="margin-top:10px">
                <el-form-item>
                    <!--<el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>-->
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
    </div>
    <script type="text/javascript">
        Vue.component('treeselect', VueTreeselect.Treeselect)

        var app = new Vue({
            el: '#app',
            data: {
                id: '',
                //mydata: PersonInChargeTree,
                //score: [],
                tableData: [],
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    Type: '',//日常评估考核类别名称
                    contractorName: '', //"承包商名称"
                    participant: null,
                    assessTypeId: '',
                    projectName: '',
                    cbS_DayCheckDetail: [],
                    evaluationResults:''

                },
                dayCheckTaskID:'',
                Type: [],
                CBS_Lists: [],
                //ContractorName: [],
                //participant: [],

                ListItem: ListItem,
                //表单验证
                rules: {
                    assessTypeId: [
                        verification.NotNull,
                    ],
                    cbsListID: [
                        verification.NotNull,
                    ],
                    assessUserId :[
                        verification.NotNull,
                    ],
                }
            },
           
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            if (mythis.Form.assessTypeId == null || mythis.Form.assessTypeId == "" || mythis.Form.assessTypeId == undefined) {
                                alert('请选择承包商类型');
                                return;
                            }

                            if (mythis.Form.cbsListID == null || mythis.Form.cbsListID == "" || mythis.Form.cbsListID == undefined) {
                                alert('请选择承包商');
                                return;}

                            if (mythis.Form.assessUserId == null || mythis.Form.assessUserId == "" || mythis.Form.assessUserId == undefined) {
                                alert('请选择评估人');
                                return; }
                            if (mythis.Form.assessDate == null || mythis.Form.assessDate == "" || mythis.Form.assessDate == undefined) {
                                alert('请选择评估日期');
                                return;}

                            if (mythis.Form.cbS_DayCheckDetail == null || mythis.Form.cbS_DayCheckDetail.length == 0) {
                                alert('没有考核内容');
                                return;
                            }
                            //onSubmitForm(this, '/api/CBS_DayCheck/Save', mythis.Form);
                            mythis.Form.dayCheckTaskID = mythis.dayCheckTaskID;
                            for (var z = 0; z < mythis.CBS_Lists.length; z++) {
                                if (mythis.Form.cbsListID == mythis.CBS_Lists[z].id) {
                                    mythis.Form.contractorName = mythis.CBS_Lists[z].contractorName;
                                    break;
                                }
                            }
                            var list = mythis.Form.cbS_DayCheckDetail;
                            //循环考核明细
                            var isScore = "0";
                            var tempsum = 0;
                            for (var i = 0; i < list.length; i++) {
                                tempsum = parseInt(tempsum) + parseInt(list[i].score);
                                if (parseInt(list[i].score) < 0 || parseInt(list[i].score) > parseInt(list[i].fullScore)) {
                                    alert(list[i].cbS_DayCheckItem.checkProject + "得分不能大于" + list[i].fullScore);
                                    isScore = "1";
                                    return;
                                }
                               
                            }
                            if (parseInt(tempsum) > 100) {
                                alert('总分不能大于100');
                                return;
                            }
                            mythis.Form.fraction = tempsum;
                            if (isScore == "0") {
                               
                                myAjax("post", mythis, '/api/CBS_DayCheck/Save', mythis.Form, function (response1) {
                                    var cbSDayCheckId = response1.data; //日常评估考核ID

                                    //循环考核明细
                                    for (var j = 0; j < list.length; j++) {
                                        list[j].cbSDayCheckId = cbSDayCheckId;
                                        myAjax("post", mythis, '/api/CBS_DayCheckDetail/Save', list[j], function (response4) {
                                        });
                                    }
                                    showMessage(msg.OperatingOk, 'success');
                                    parent.app.ListItem.dialogVisible = false;
                                
                                });
                            }
                        } else {
                            //验证失败
                            return false;
                        }
                    });
                },
                getData: function () {
                    var mythis = this;
                    if (mythis.id == null || mythis.id == "" || mythis.id == undefined || mythis.id == "undefined") {
                        mythis.Form.cbS_DayCheckDetail = [];
                    } else {
                        getData(mythis, '/api/CBS_DayCheck/get?id=' + mythis.id);
                        myAjax("post", mythis, '/api/CBS_DayCheckDetail/GetList', { model: { cbSDayCheckId: mythis.id }, offset: 0, limit: 100 }, function (response) {
                            mythis.Form.cbS_DayCheckDetail = response.data.pageData;
                            console.log('h1', response.data.pageData);
                        }, false);
                    }
                },
                //初始化承包商类型
                getTypeList: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/CBS_DayCheckItem/CBSsglbGetList', { model: { category: 'cbssglb' }, offset: 0, limit: 100 }, function (response) {
                        mythis.Type = response.data;

                        //console.log(response.data.pageData);
                    }, false);
                },
                //初始化承包商下拉框
                getCBS_List: function () {
                    var mythis = this;
                    if (mythis.assessTypeId == null || mythis.assessTypeId == "" || mythis.assessTypeId == undefined) {
                        myAjax("post", this, '/api/CBS_List/GetList', { model: { status: '', CreateFactory: null }, offset: 0, limit: 100 }, function (response) {
                            mythis.CBS_Lists = response.data.pageData;
                            console.log('h1', response.data.pageData);
                        }, false);
                    } else {
                        myAjax("post", this, '/api/CBS_List/GetList', { model: { constructionCategory: mythis.assessTypeId, CreateFactory: null }, offset: 0, limit: 100 }, function (response) {
                            mythis.CBS_Lists = response.data.pageData;
                            console.log('h1', response.data.pageData);
                        }, false);
                    }
                },
                changeAssessType: function (assessTypeId) {
                    var mythis = this;
                    if (assessTypeId == null || assessTypeId == "" || assessTypeId == undefined) { } else {
                        myAjax("post", mythis, '/api/CBS_DayCheckItem/GetList', {
                            model: { assessTypeId: assessTypeId }, offset: 0, limit: 100
                        }, function (response) {
                            console.log(response);
                            if (response.data.pageData.length == 0) {
                                mythis.tableData = [];
                            } else {
                                mythis.tableData = response.data.pageData;
                                mythis.Form.cbS_DayCheckDetail = [];
                                for (var i = 0; i < mythis.tableData.length; i++) {
                                    mythis.Form.cbS_DayCheckDetail.push({ cbS_DayCheckItem: { checkProject: mythis.tableData[i].checkProject}, cbSDayCheckItemId: mythis.tableData[i].id, fullScore: mythis.tableData[i].points, score:0});
                                }

                            }
                        });
                    }
                },
                 postChange: function (val) {
                     //根据类型 筛选承包商
                     this.getCBS_List();
                     this.changeAssessType(val);

                }
            },
            mounted: function () {
                //this.participant = fn(this.mydata, "0");
                
                //this.Type = getDicData('29');
                //this.ContractorName = getDicData('139');
                this.id = getUrlParam("id");
                this.dayCheckTaskID = getUrlParam("dayCheckTaskID");
                this.getTypeList();//评估类别
                this.getCBS_List();//承包商
                

                this.getData();
            }
        });
    </script>
</body>

</html>